var LTEtotalFlowChar;
var LTEflowRanking;
var LTEflowTrend;
var LTEterminal;
var LTEScaleChar;
var eHRPDtotalFlowChar;
var eHRPDflowRanking;
var eHRPDflowTrend;
var eHRPDterminal;
var eHRPDScaleChar;
var spFlowChar;
var areaChar;

var httpType="网页浏览";

var param = new Object({
	init:function(){
		this.timeSize = ''
		this.beginDate = ''
		this.endDate = ''
		this.businessBigTypeId = ''
	},
	setTimeSizeParam:function(timeSize){
		
		var checkDate = $("#checkDate").val();
		var dayCheckDate=new XDate(checkDate);
		var dayFirstDay =dayCheckDate.toString('yyyy-MM-dd HH:mm:ss');
		var dayEndDay =dayCheckDate.toString('yyyy-MM-dd ')+("23:59:59");
		
		
		var firstDate = new Date(checkDate);
		firstDate.setDate(1); //第一天
		var monthFirstDay=new XDate(firstDate).toString('yyyy-MM-dd')+" 00:00:00";
		var endDate = new Date(firstDate);
		endDate.setMonth(firstDate.getMonth()+1);
		endDate.setDate(0);
		var monthEndDay=new XDate(endDate).toString('yyyy-MM-dd')+(" 23:59:59");
		
		
		var time = new Date(checkDate);
		time.setDate(time.getDate() - time.getDay() + 1);
		var weekFirstDay=new XDate(time).toString('yyyy-MM-dd')+" 00:00:00";
		time.setDate(time.getDate() + 6);
		var weekEndDay=new XDate(time).toString('yyyy-MM-dd')+(" 23:59:59");

		switch(timeSize) {
			case 'day' :
				this.beginDate = dayFirstDay
				this.endDate = dayEndDay
				break
			case 'week' :
				this.beginDate = weekFirstDay
				this.endDate = weekEndDay
				break
			case 'month' :
				this.beginDate = monthFirstDay
				this.endDate = monthEndDay
				break
		}
	},
	setParam:function(){
		this.init();
		this.timeSize = $('input:radio[name="timeSize"]:checked').val();
		this.businessBigTypeId = $("#businessBigTypeId").val();
		this.setTimeSizeParam(this.timeSize);
	}
});

$(function() {
	$("#businessBigTypeId").combobox();
	
	//图表  
	LTEtotalFlowChar = echarts.init(document.getElementById('LTEtotalFlowChar'));
	LTEflowRanking = echarts.init(document.getElementById('LTEflowRanking'));
	LTEflowTrend = echarts.init(document.getElementById('LTEflowTrend'));
	LTEterminal = echarts.init(document.getElementById('LTEterminal'));
	LTEScaleChar = echarts.init(document.getElementById('LTEScaleChar'));
	eHRPDtotalFlowChar = echarts.init(document.getElementById('eHRPDtotalFlowChar'));
	eHRPDflowRanking = echarts.init(document.getElementById('eHRPDflowRanking'));
	eHRPDflowTrend = echarts.init(document.getElementById('eHRPDflowTrend'));
	eHRPDterminal = echarts.init(document.getElementById('eHRPDterminal'));
	eHRPDScaleChar = echarts.init(document.getElementById('eHRPDScaleChar'));
	spFlowChar = echarts.init(document.getElementById('spFlowChar'));
	areaChar = echarts.init(document.getElementById('areaChar'));
	
	$("#http").hide();
	$("#gm").hide();
});

function resetQueryForm() {
	$('#queryForm')[0].reset();
}

function getList(){
	param.setParam();
	
	initLTEflowRanking();
	initeHRPDflowRanking();
	initLTEflowTrend();
	initeHRPDflowTrend();
	initLTEterminal();
	initeHRPDterminal();
	
	var totalFlow=$("#totalFlow");
	var gm=$("#gm");
	var http=$("#http");
	if(param.businessBigTypeId==""){
		totalFlow.show();
		gm.hide();
		http.hide();
		
		initLTEtotalFlowChar();
		initeHRPDtotalFlowChar();
	}else if(param.businessBigTypeId==httpType){
		totalFlow.hide();
		gm.show();
		http.show();
		
		initLTEScaleChar();
		initeHRPDScaleChar();
		initspFlowChar();
		initareaChar();
	}else{
		totalFlow.hide();
		gm.show();
		http.hide();
		
		initLTEScaleChar();
		initeHRPDScaleChar();
	}
}

function initLTEtotalFlowChar(){
	//查询  
	LTEtotalFlowChar.clear();
	LTEtotalFlowChar.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getLTEtotalFlowChar?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			LTEtotalFlowChar.setOption(data, true);
			LTEtotalFlowChar.hideLoading();
		}
	});
}

function initeHRPDtotalFlowChar(){
	//查询  
	eHRPDtotalFlowChar.clear();
	eHRPDtotalFlowChar.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/geteHRPDtotalFlowChar?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			eHRPDtotalFlowChar.setOption(data, true);
			eHRPDtotalFlowChar.hideLoading();
		}
	});
}

function initLTEflowRanking(){
	//查询  
	LTEflowRanking.clear();
	LTEflowRanking.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getLTEflowRanking?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			LTEflowRanking.setOption(data, true);
			LTEflowRanking.hideLoading();
		}
	});
}

function initeHRPDflowRanking(){
	//查询  
	eHRPDflowRanking.clear();
	eHRPDflowRanking.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/geteHRPDflowRanking?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			eHRPDflowRanking.setOption(data, true);
			eHRPDflowRanking.hideLoading();
		}
	});
}

function initspFlowChar(){
	//查询  
	spFlowChar.clear();
	spFlowChar.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getspFlowChar?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			spFlowChar.setOption(data, true);
			spFlowChar.hideLoading();
		}
	});
}

function initareaChar(){
	//查询  
	areaChar.clear();
	areaChar.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getareaChar?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			areaChar.setOption(data, true);
			areaChar.hideLoading();
		}
	});
}

function initLTEflowTrend(){
	//查询  
	LTEflowTrend.clear();
	LTEflowTrend.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getLTEflowTrend?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			LTEflowTrend.setOption(data, true);
			LTEflowTrend.hideLoading();
		}
	});
}

function initeHRPDflowTrend(){
	//查询  
	eHRPDflowTrend.clear();
	eHRPDflowTrend.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/geteHRPDflowTrend?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			eHRPDflowTrend.setOption(data, true);
			eHRPDflowTrend.hideLoading();
		}
	});
}

function initLTEScaleChar(){
	//查询  
	LTEScaleChar.clear();
	LTEScaleChar.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getLTEScaleChar?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			LTEScaleChar.setOption(data, true);
			LTEScaleChar.hideLoading();
		}
	});
}

function initeHRPDScaleChar(){
	//查询  
	eHRPDScaleChar.clear();
	eHRPDScaleChar.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/geteHRPDScaleChar?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			eHRPDScaleChar.setOption(data, true);
			eHRPDScaleChar.hideLoading();
		}
	});
}

function initLTEterminal(){
	//查询  
	LTEterminal.clear();
	LTEterminal.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/getLTEterminal?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			LTEterminal.setOption(data, true);
			LTEterminal.hideLoading();
		}
	});
}

function initeHRPDterminal(){
	//查询  
	eHRPDterminal.clear();
	eHRPDterminal.showLoading({
		text : '正在努力的读取数据中...'
	});
	$.ajax({
		type : "POST",
		url : "../../excavantionAnalysis/applicationAnalysis/geteHRPDterminal?rand="
				+ Math.random(),
		dataType : "json",
		"data" : {
			"param" : JSON.stringify(param)
		},
		success : function(data) {
			eHRPDterminal.setOption(data, true);
			eHRPDterminal.hideLoading();
		}
	});
}